package com.serve.oa.listener;

import com.serve.oa.entity.comUser;
import com.serve.oa.service.ComOrganizationService;
import org.flowable.engine.delegate.TaskListener;
import org.flowable.task.service.delegate.DelegateTask;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.List;
import java.util.Map;


@Component
public class BossTaskHandler implements TaskListener {

    @Autowired
    private ComOrganizationService comOrganizationService;

    private static BossTaskHandler myListener;

    @PostConstruct
    public void init() {
        myListener = this;
        myListener.comOrganizationService = this.comOrganizationService;
    }


    @Override
    public void notify(DelegateTask delegateTask) {


        //3为行政部门的id
        List<Map> user = myListener.comOrganizationService.getUserIdBYorgid(3L);
        //System.out.println(user.toString()+119);


        if(!user.isEmpty()){

            for(Map map2 : user){

                delegateTask.addCandidateUser(map2.get("user_id").toString());
            }
        }
        //delegateTask.addCandidateUser("王五");
       // delegateTask.addCandidateUser("赵六");
        //System.out.println("王五、赵六");
    }


}

